﻿#include "OperPropTreeEvent.h" 
#include "GUIWidget/TreeItemTypes.h"
#include "GUIWidget/BrowserWidget.h"
#include "GUIWidget/WidgetBrowserTable.h"
#include "GUIWidget/BrowserTableHandlerMaterialFluid.h"
#include "GUIWidget/BrowserTableHandlerSpectraModalDensity.h"
#include "GUIWidget/BrowserTableHandlerSpectraWavenumber.h"
#include "GUIWidget/BrowserTableHandlerSpectraDampingLossFactor.h"
#include "GUIWidget/BrowserTableHandlerSpectraAbsorptionCoefficient.h"
#include "GUIWidget/BrowserTableHandlerSpectraCouplingLossFactor.h"
#include "GUIWidget/BrowserTableHandlerSpectraAcceleration.h"
#include "GUIWidget/BrowserTableHandlerSpectraAngularVelocity.h"
#include "GUIWidget/BrowserTableHandlerSpectraEnergy.h"
#include "GUIWidget/BrowserTableHandlerSpectraForce.h"
#include "GUIWidget/BrowserTableHandlerSpectraInsertionLoss.h"
#include "GUIWidget/BrowserTableHandlerSpectraMoment.h"
#include "GUIWidget/BrowserTableHandlerSpectraPower.h"
#include "GUIWidget/BrowserTableHandlerSpectraPressure.h"
#include "GUIWidget/BrowserTableHandlerSpectraShearModulus.h"
#include "GUIWidget/BrowserTableHandlerSpectraTransmissionLoss.h"
#include "GUIWidget/BrowserTableHandlerSpectraVelocity.h"
#include "GUIWidget/BrowserTableHandlerMaterialIsosolid.h"
#include "GUIWidget/BrowserTableHandlerMaterialVisESolid.h"
#include "GUIWidget/BrowserTableHandlerMaterialFoam.h"
#include "GUIWidget/BrowserTableHandlerMaterialFiber.h"
#include "GUIWidget/BrowserTableHandlerMaterialFE.h"
#include "GUIWidget/BrowserTableHandlerPhysicsBeam.h"
#include "GUIWidget/BrowserTableHandlerPhysicsUniform.h"
#include "GUIWidget/BrowserTableHandlerPhysicsGeneralLaminate.h"
#include "GUIWidget/BrowserTableHandlerPhysicsRibbed.h"
#include "GUIWidget/BrowserTableHandlerNCTLayUp.h"
#include "GUIWidget/BrowserTableHandlerNCTUserDefined.h"
#include "GUIWidget/BrowserTableHandlerNCTMultiple.h"
#include "GUIWidget/BrowserTableHandlerPhysicsFEProperty.h"
#include "GUIFrame/CentralWidget.h"
#include "GUIFrame/MainWindow.h" 
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include <QTreeWidgetItem>
#include <QDebug>

namespace GUIOper
{
    void OperatorPropTreeEvent::itemClicked(QTreeWidgetItem* item, int colum)
    {
        //从数据结构中获取表单对象
        GUI::MainWindow* mw = dynamic_cast<GUI::MainWindow*>(FITKAPP->getGlobalData()->getMainWindow());
        //切换到浏览页
        mw->getCentralWidget()->getGraphArea()->switch2AWindow(GUI::GraphAbstractSubWin::SubWinType::Browser);
        GUI::BrowserWidget* bw = mw->getCentralWidget()->getGraphArea()->getCurrentWindow<GUI::BrowserWidget>();
        if (bw == nullptr) return;
        GUI::WidgetBrowserTable* browserTable = bw->getTable();

        GUI::BrowserTableAbstractHandler* handler = nullptr;

        // 获取对应操作器
//         auto operatorRepo = Core::FITKOperatorRepo::getInstance();
//         if (operatorRepo == nullptr)
//             return;
        //获取type  
        GUI::PropTreeItemsType itemType = (GUI::PropTreeItemsType)item->type();
        switch (itemType)
        {
        //材料
        case GUI::PTMatFluids:
            handler = new GUI::BrowserTableHandlerMaterialFluid(browserTable); break;
        case GUI::PTMatIsoSolid:
            handler = new GUI::BrowserTableHandlerMaterialIsoSolid(browserTable); break;
        case GUI::PTMatViscoElastic:
            handler = new GUI::BrowserTableHandlerMaterialVisESolid(browserTable); break;
        case GUI::PTMatFoam:
            handler = new GUI::BrowserTableHandlerMaterialFoam(browserTable); break;
        case GUI::PTMatFiber:
            handler = new GUI::BrowserTableHandlerMaterialFiber(browserTable); break;
        case GUI::PTMatFEMaterial:
            handler = new GUI::BrowserTableHandlerMaterialFE(browserTable); break;

        //频谱
        case GUI::PTSModalDensity:
            handler = new GUI::BrowserTableHandlerSpectraModalDensity(browserTable); break;
        case GUI::PTSWavenumber:
            handler = new GUI::BrowserTableHandlerSpectraWavenumber(browserTable); break;
        case GUI::PTSDamping:
            handler = new GUI::BrowserTableHandlerSpectraDampingLossFactor(browserTable); break;
        case GUI::PTSAbsorption:
            handler = new GUI::BrowserTableHandlerSpectraAbsorptionCoefficient(browserTable); break;
        case GUI::PTSCoupling:
            handler = new GUI::BrowserTableHandlerSpectraCouplingLossFactor(browserTable); break;
        case GUI::PTSAcceleration:
            handler = new GUI::BrowserTableHandlerSpectraAcceleration(browserTable); break;
        case GUI::PTSAnlrVelocity:
            handler = new GUI::BrowserTableHandlerSpectraAngularVelocity(browserTable); break;
        case GUI::PTSEnergy:
            handler = new GUI::BrowserTableHandlerSpectraEnergy(browserTable); break;
        case GUI::PTSForce:
            handler = new GUI::BrowserTableHandlerSpectraForce(browserTable); break;
        case GUI::PTSInsertionLoss:
            handler = new GUI::BrowserTableHandlerSpectraInsertionLoss(browserTable); break;
        case GUI::PTSMoment:
            handler = new GUI::BrowserTableHandlerSpectraMoment(browserTable); break;
        case GUI::PTSPower:
            handler = new GUI::BrowserTableHandlerSpectraPower(browserTable); break;
        case GUI::PTSPressure:
            handler = new GUI::BrowserTableHandlerSpectraPressure(browserTable); break;
        case GUI::PTSShearModulus:
            handler = new GUI::BrowserTableHandlerSpectraShearModulus(browserTable); break;
        case GUI::PTSTransmissionLoss:
            handler = new GUI::BrowserTableHandlerSpectraTransmissionLoss(browserTable); break;
        case GUI::PTSVelocity:
            handler = new GUI::BrowserTableHandlerSpectraVelocity(browserTable); break;

        //物理属性
        case GUI::PTPPBeam:
            handler = new GUI::BrowserTableHandlerPhysicsBeam(browserTable); break;
        case GUI::PTPPShellUniform:
            handler = new GUI::BrowserTableHandlerPhysicsUniform(browserTable); break;
        case GUI::PTPPShellGeneralLaminate:
            handler = new GUI::BrowserTableHandlerPhysicsGeneralLaminate(browserTable); break;
        case GUI::PTPPShellRibbed:
            handler = new GUI::BrowserTableHandlerPhysicsRibbed(browserTable); break;
        case GUI::PTPPFEProperty:
            handler = new GUI::BrowserTableHandlerPhysicsFEProperty(browserTable); break;

        //声学包
        case GUI::PTNCTLayUp:
            handler = new GUI::BrowserTableHandlerNCTLayUp(browserTable); break;
        case GUI::PTNCTUserDef:
            handler = new GUI::BrowserTableHandlerNCTUserDefined(browserTable); break;
        case GUI::PTNCTMultiple:
            handler = new GUI::BrowserTableHandlerNCTMultiple(browserTable); break;
        default: break;
        }
         
        if (handler)
            browserTable->update(handler);
    }

    void OperatorPropTreeEvent::itemDouleClicked(QTreeWidgetItem* item, int colum)
    {

    }

}



